<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        canvas {
            border: 1px dashed red;
        }
    </style>
</head>
<body>
    <canvas width="600" height="400"></canvas>
</body>
<script>
    var cas = document.querySelectorAll( 'canvas' )[ 0 ];
    var ctx = cas.getContext( '2d' );


    ctx.fillStyle = 'red';
    ctx.moveTo( 100, 100 );
    ctx.lineTo( 200, 100 );
    ctx.lineTo( 200, 200 );
    ctx.closePath();
    ctx.stroke();

    ctx.beginPath();

    ctx.moveTo( 300, 100 );
    ctx.lineTo( 500, 100 );
    ctx.lineTo( 500, 200 );
    ctx.closePath();
    ctx.fill();
   

</script>
</html>